
// <copyright file="InfinitiveEditorUserControl.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The infinitive editor user control.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Windows.Forms
{
    using System;
    using System.Windows.Forms;

    using SubhadraSolutions.Sharp.Utils.Collections.Generic;

    /// <summary>
    /// The infinitive editor user control.
    /// </summary>
    public partial class InfinitiveEditorUserControl : UserControl
    {
        #region Constructors and Finalizers

        /// <summary>
        /// Initializes a new instance of the <see cref="InfinitiveEditorUserControl"/> class.
        /// </summary>
        public InfinitiveEditorUserControl()
        {
            this.InitializeComponent();
        }

        #endregion Constructors and Finalizers

        #region Public Events

        /// <summary>
        /// The on scroll value changed.
        /// </summary>
        public event EventHandler<GenericEventArgs<int>> OnScrollValueChanged;

        #endregion Public Events

        #region Public Methods and Operators

        /// <summary>
        /// The initialize scroll.
        /// </summary>
        /// <param name="maxItems">
        /// The max items.
        /// </param>
        public void InitializeScroll(int maxItems)
        {
            this.vScrollBar1.ValueChanged -= this.vScrollBar1_ValueChanged;
            this.vScrollBar1.Minimum = 1;
            this.vScrollBar1.Value = this.vScrollBar1.Minimum;
            this.vScrollBar1.Maximum = maxItems;
            this.vScrollBar1.ValueChanged += this.vScrollBar1_ValueChanged;
        }

        /// <summary>
        /// The set editor control.
        /// </summary>
        /// <param name="control">
        /// The control.
        /// </param>
        public void SetEditorControl(Control control)
        {
            control.Dock = DockStyle.Fill;
            this.panel1.Controls.Clear();
            this.panel1.Controls.Add(control);
        }

        #endregion Public Methods and Operators

        #region Methods

        /// <summary>
        /// The v scroll bar 1_ value changed.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void vScrollBar1_ValueChanged(object sender, EventArgs e)
        {
            if (this.OnScrollValueChanged != null)
            {
                this.OnScrollValueChanged(this, new GenericEventArgs<int>(this.vScrollBar1.Value));
            }
        }

        #endregion Methods
    }
}
